package dobest.ray.com.jiongjiong.activity.action.selftest.NearVision;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import dobest.ray.com.jiongjiong.R;
import dobest.ray.com.jiongjiong.activity.BaseActivity;
import dobest.ray.com.jiongjiong.activity.action.selftest.LetterETestActivity;
import dobest.ray.com.jiongjiong.views.NavigationBar;

/**
 * Created by Ray on 2016/3/24.
 * https://github.com/ray0807
 */
public class CheckRightEyeGuildActivity extends BaseActivity implements View.OnClickListener {

    private static String INTENT_IS_FAR = "INTENT_IS_FAR";
    private boolean isRight = true;
    private boolean isFarAway = true;
    private static final String INTENT_IS_RIGHT = "INTENT_IS_RIGHT";

    private Button btn_start;
    private TextView tv_notice;
    private ImageView iv_check_right;

    public static void startEyeGuildActivity(Context context, boolean isRight, boolean isFarAway) {
        Intent intent = new Intent(context, CheckRightEyeGuildActivity.class);
        intent.putExtra(INTENT_IS_RIGHT, isRight);
        intent.putExtra(INTENT_IS_FAR, isFarAway);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_check_right_eye_guild);
        findViews();
        init();
        addListeners();
    }

    @Override
    public void findViews() {
        navi = (NavigationBar) findViewById(R.id.navi);

        navi.setBackListener(R.mipmap.img_back, "");
        isRight = getIntent().getBooleanExtra(INTENT_IS_RIGHT, true);
        isFarAway = getIntent().getBooleanExtra(INTENT_IS_FAR, false);
        if (isFarAway) {
            navi.setTitle("远视测试说明");
        } else {
            navi.setTitle("近视测试说明");
        }
        btn_start = (Button) findViewById(R.id.btn_start);
        tv_notice = (TextView) findViewById(R.id.tv_notice);
        iv_check_right = (ImageView) findViewById(R.id.iv_check_right);
    }

    @Override
    public void init() {
        if (!isRight) {
            tv_notice.setText("遮住右眼,开始测试左眼");
            iv_check_right.setImageResource(R.mipmap.img_near_test_check_left);
        }

    }

    @Override
    public void addListeners() {
        btn_start.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_start:
                if (isRight) {
                    //右眼
                    LetterETestActivity.startLetterETestActivity(this, true, isFarAway);
                    finish();
                } else {
                    //左眼
                    LetterETestActivity.startLetterETestActivity(this, false, isFarAway);
                    finish();
                }
                break;
        }
    }
}
